// 封装request请求
export default function (config) {
    // 如果本地有数据，则需要携带token
    
    const mytoken = uni.getStorageSync('token')
	// console.log(mytoken)
    if (mytoken) {
        config.header = {
            "Authorization": mytoken
        }
    } else { // 默认如果没有登录时，也可以操作其他功能
        config.header={ // 使用若依的超管登录后获取的token来测并使用
			"Authorization": 'eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6ImJkZGQ0NGJlLWRlNGMtNDJhNC04ZmZiLWY3ODFmN2ZlMjU2NiIsInVzZXJuYW1lIjoiYWRtaW4ifQ.PHernMSzs-Z3jnP_crHoU33cMEBgA5tRAfzei9Q3HlVMn2q6LT6q2ngfLO4kkTkvM7RSKUZgDgLw6q00hzuooA'
        }
    }
	// #ifdef H5
    uni.request({
        url: "http://localhost:9999/api" + config.url,
        method: config.method,
        data: config.data,
		params: config.params,
        header: config.header,
        success: config.success
    })
	// #endif
	// #ifdef MP-WEIXIN
	uni.request({
	    url: "http://localhost:8080" + config.url,
	    method: config.method,
	    data: config.data,
		params: config.params,
	    header: config.header,
	    success: config.success
	})
	// #endif
}